<?php
 //header('Content-Type:text/html;charset=utf-8');
class oracldb
{
	private $dbconn=null;
	function oracldb()
	{
		if($this->dbconn==null)
		{
			$this->dbconn=OCILogon("scfao","fao","(DESCRIPTION =
			  (ADDRESS_LIST =
			  (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.8.176)(PORT = 1521))
			  )
			  (CONNECT_DATA =
			  (SERVICE_NAME = ORCL)
			  ))");  
			  if($this->dbconn==false)
			  {
				throw_exception('连接数据库失败');
			  }
			  
		}
		
	}
	function login($empno,$idno)
	{
		$sql="select * from t_vst_person where EMP_NO='$empno' and Certificate_num='$idno'"; 
		$ora_test = oci_parse($this->dbconn,$sql);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
	}
	
	function selectpass($idno)
	{
		$sql="select * from t_vst_pass where Certificate_num='$idno'"; 
		$ora_test = oci_parse($this->dbconn,$sql);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
	}
	
	function selectmember($idno)
	{
		$sql="select * from t_vst_member Left Join t_vst_group on t_vst_member.group_id=t_vst_group.group_id left join t_vst_place on t_vst_member.group_id=t_vst_place.group_id where t_vst_member.certificate_num='$idno'";
		$ora_test = oci_parse($this->dbconn,$sql);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
	}
	function getStatus($group_id)
	{
		$sql="select business_activity from(select  * from t_vst_groupprocess where group_id='$group_id' order by order_by desc)a where rownum=1";
		$sql2="select biz_type from(
select  * from t_vst_groupexgresult where group_id='$group_id' order by order_by desc
)a where rownum=1";
        $ora_test = oci_parse($this->dbconn,$sql2);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
	}
	
	function getPassinout($passnum)
	{
		$sql="select operate_type,reason,name,create_operator,create_date from t_vst_passoutin where pass_num ='$passnum' order by create_date desc";
		$ora_test = oci_parse($this->dbconn,$sql);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
	}
	function getPassinouttop($passnum)
	{
		$sql="select * from (select operate_type,reason,name,create_operator,create_date from t_vst_passoutin where pass_num ='$passnum' order by create_date desc)a where rownum=1";
		$ora_test = oci_parse($this->dbconn,$sql);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
	}
	
	function select($empno)
	{
		//$sql='select * from t_vst_pass';
		$sql="select * from t_vst_person where EMP_NO='$empno'"; 
		$ora_test = oci_parse($this->dbconn,$sql);
		oci_execute($ora_test,OCI_DEFAULT);
		return $ora_test;
		
	}
	function closedb()
	{
		OCILogOff($this->$dbconn);
		$this->dbconn=null;
	}
	
	function test()
	{
		return $this->dbconn;
	}
	
	
  
}

?>